import Vue from 'vue'
import Vuex from 'vuex'

import login from './modules/login.js'
import cart from './modules/cart.js'

Vue.use(Vuex)

export default new Vuex.Store({
  getters: {
    sum () {
      return cart.state.cartList.reduce((prev, now) => {
        return prev + now.num
      }, 0)
    }
  },
  modules: {
    login,
    cart
  }
})
